﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall), AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class MessageService : IMessageService
    {
        public string DeleteSendMessage(List<string> UserMessageID, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.DeleteSendMessage(UserMessageID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return returnStr;
        }

        public string DeleteUserMessage(List<string> UserMessageID, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.Delete(UserMessageID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return returnStr;
        }

        public DataSet GetAllUnreadUserMessage(PubParasInfo pubParasInfo)
        {
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.GetAllUnreadUserMessage();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return null;
        }

        public DataSet GetInMessageInfoByQueryEntity(UserMessageQueryEntity userMessageQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.GetInMessageByQueryEntity(userMessageQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return null;
        }

        public DataSet GetMessageCommandInfoByQueryEntity(MessageCommandQueryEntity messageCommandQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.GetMessageCommandInfoByQueryEntity(messageCommandQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return null;
        }

        public DataSet GetMessageCommandInfoBySqlWhere(List<string> sqlWhere, MessageCommandQueryEntity messageCommandQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.GetMessageCommandInfoByQueryEntity(sqlWhere, messageCommandQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return null;
        }

        public List<MessageCommandInfo> GetMessageCommandInfosByQueryEntity(MessageCommandQueryEntity messageCommandQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.GetMessageCommandInfosByQueryEntity(messageCommandQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return null;
        }

        public List<MessageCommandInfo> GetMessageCommandInfosBySqlWhere(List<string> sqlWhere, MessageCommandQueryEntity messageCommandQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.GetMessageCommandInfosByQueryEntity(sqlWhere, messageCommandQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return null;
        }

        public DataSet GetUserMessageAllInfo(PubParasInfo pubParasInfo)
        {
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.GetAllInfo();
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return null;
        }

        public UserMessageInfo GetUserMessageInfoByID(string userMessageID, PubParasInfo pubParasInfo)
        {
            UserMessageInfo userMessageInfo = new UserMessageInfo();
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return (userMessageBLL.GetInfoByID(userMessageID) as UserMessageInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return userMessageInfo;
        }

        public DataSet GetUserMessageInfoByQueryEntity(UserMessageQueryEntity userMessageQuery, PubParasInfo pubParasInfo)
        {
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.GetInfoByQueryEntity(userMessageQuery);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return null;
        }

        public UserUnreadMessageInfo GetUserUnreadMessageInfoByID(string userID, PubParasInfo pubParasInfo)
        {
            UserUnreadMessageInfo userUnreadMessageInfo = new UserUnreadMessageInfo();
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return (userMessageBLL.GetUserUnreadMessageByID(userID) as UserUnreadMessageInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return userUnreadMessageInfo;
        }

        public string InsertMessageCommandInfo(MessageCommandInfo messageCommandInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.InsertMessageCommand(messageCommandInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return returnStr;
        }

        public bool InsertMessageCommandInfos(List<MessageCommandInfo> messageCommandInfos, PubParasInfo pubParasInfo)
        {
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.InsertMessageCommands(messageCommandInfos);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return false;
        }

        public string InsertUserMessageInfo(UserMessageInfo userMessageInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.Insert(userMessageInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return returnStr;
        }

        public string InsertUserMessageInfoList(List<UserMessageInfo> userMessageInfoList, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.InsertList(userMessageInfoList);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return returnStr;
        }

        public string UpdateMarkUserMessageInfo(string rowIDs, string isRead, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.UpdateMarkUserMessage(rowIDs, isRead);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return returnStr;
        }

        public string UpdateMessageCommandInfo(MessageCommandInfo messageCommandInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                MessageBLL messageBLL = new MessageBLL(pubParasInfo);
                return messageBLL.UpdateMessageCommand(messageCommandInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "MessageService异常");
            }
            return returnStr;
        }

        public string UpdateUserMessageInfo(UserMessageInfo userMessageInfo, PubParasInfo pubParasInfo)
        {
            string returnStr = string.Empty;
            try
            {
                UserMessageBLL userMessageBLL = new UserMessageBLL(pubParasInfo);
                return userMessageBLL.Update(userMessageInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "UserMessageService异常");
            }
            return returnStr;
        }
    }
}

